<!DOCTYPE html>
<!-- <html xmlns:th="http://www.thymeleaf.org"> -->
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title></title>
<script type="text/javascript" src="../js/jquery-2.1.1.min.js"></script>
<link rel="stylesheet" href="../js/layui/css/layui.css">
<script src="../js/layui/layui.all.js" type="text/javascript"></script>
<script type="text/javascript" src="../js/WebCalendar.js"></script>
<script type="text/javascript">
	
$(function (){
	checkseach();
	//location.reload();
})
var tabobj;
	function checkseach(){
		var dyd = $("#dyd option:selected").val();
		
		 layui.use(['form','layer', 'table'], function(){
			 
			  var laydate = layui.laydate //日期
			  ,layer = layui.layer //弹层
			  ,table = layui.table //表格
			 ,form = layui.form;
			 
				//执行渲染
				tabobj =  table.render({
				    elem: '#dytab',//指定原始表格元素选择器（推荐id选择器）
				    toolbar:"#dydiv"
				    ,url:"selAllByAskId"
				    ,method:'post',
				    page:true,
				    where:{
				    	isOpen : dyd
				    	
				    }
				   ,width:1700
				    ,height: 515 //容器高度
				    ,cols:  [[ //标题栏
				        {checkbox: true,}
				        ,{field: 'id', title: 'ID', width: 80}
				        ,{field: 'studentId', title: '学生ID', width: 80}
				        ,{field: 'studentName', title: '学生名', width: 100}
				        ,{field: 'messageContent', title: '消息', width: 260}
				        ,{field: 'isOpen', title: '是否已读', width: 100}
				        ,{field: 'createTime', title: '时间', width:200}
				        ,{fixed: 'right', width:200, title: '操作',align:'center', toolbar: '#barDemo'}
				      ]]
				  });
		 })
		// location.reload()
	}
	
	 layui.use(['form','layer', 'table'], function(){
		 
		  var layer = layui.layer //弹层
		  ,table = layui.table //表格
		 ,form = layui.form;
		//监听工具条
		  table.on('tool(demo)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
		    var data = obj.data //获得当前行数据
		    ,layEvent = obj.event; //获得 lay-event 对应的值
				form.val("dyckform",data);
		    if(layEvent === 'ck'){
		    	layer.open({
		    		 title:'学员消息',
						area:['400px','500px'],
						//closeBtn:0,
						type:1,
						content:$("#dyckdiv"),
						end : function(){
							$.ajax({
					 			   url:"updDMYD",
					 			   type:"post",
					 			   data:{
					 				   id : data.id
					 			   },
					 			   dataType:"json",
					 			   success:function(res){
					 				   if(res.success){
					 					 // layer.msg(res.message)
					 		    		  tabobj.reload();
					 				   }else{
					 					  //layer.msg(res.message)
					 		    		  tabobj.reload();
					 				   }
					 			   }
					 		   })
							$("#dyckdiv").hide();
							// tabobj.reload();
			         		}
		    	 })
				}else if(layEvent === 'del'){
					layer.confirm('确认删除么', function(index){
				    	  layer.close(index);
				 		   $.ajax({
				 			   url:"delDMYD",
				 			   type:"post",
				 			   data:{
				 				   id:data.id
				 			   },
				 			   dataType:"json",
				 			   success:function(res){
				 				   if(res.success){
				 					  layer.msg(res.message)
				 		    		  tabobj.reload();
				 				   }else{
				 					  layer.msg(res.message)
				 		    		  tabobj.reload();
				 				   }
				 			   }
				 		   })
				      });
				}
		  })
	 })
	function dyclose(){
		 layer.closeAll();
		 $("#dydiv").hide();
		 tabobj.reload();
	 }
</script>
<script type="text/html" id="barDemo">
	<a class="layui-btn layui-btn-xs" lay-event="ck">查看</a>
<a class="layui-btn layui-btn-xs" lay-event="del">删除</a>
</script>
</head>
<body>
<table id="dytab" lay-filter="demo"></table>
	<div id="dydiv" style="display: none;">
		<form class="layui-form"  id="dyform"  lay-filter="dyform">
			<div class="layui-form-item">
			     <label class="layui-form-label">是否已读</label>
				    		<div class="layui-input-inline">
						      <select id="dyd"  readonly="readonly">
						         <option value="">请选择</option>
						        <option value="是">是</option>
						        <option value="否">否</option>
						       
						      </select>
    						</div>		
    			<input type="button"  value="检索" class="layui-btn  layui-icon-search"  onclick="checkseach()">
		</div>

		</form>
	</div>
	
	<div id="dyckdiv" style="display: none;">
		<form class="layui-form"   id="dyckform"  lay-filter="dyckform">
		
		<div class="layui-form-item">
			    <label class="layui-form-label">学生名</label>
			    <div class="layui-input-block">
			     	 <input type="text" id="names" name="studentName" autocomplete="off"  readonly="readonly"   placeholder="学生名" class="layui-input">
			 	 </div>
 		 </div>


 		 <div class="layui-form-item">
			    <label class="layui-form-label">时间</label>
			    <div class="layui-input-block">
			     	 <input type="text" id="age" name="createTime" autocomplete="off" readonly="readonly"     placeholder="时间" class="layui-input">
			 	 </div>
 		 </div>
 		 <div class="layui-form-item layui-form-text">
				    <label class="layui-form-label">信息内容</label>
				    <div class="layui-input-block">
				      <textarea name="messageContent" placeholder="内容"  readonly="readonly"  class="layui-textarea"></textarea>
				    </div>
				</div>


 		 <div class="layui-form-item">
		    <div class="layui-input-block">
		      <input type="button"  value="关闭" class="layui-btn"  onclick="dyclose()">
		      <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
		    </div>
  		</div>
  		</form>
	</div>

</body>
</html>